﻿using editor.cfg;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace editor
{
    public static class CopyManager
    {

        private static DData copyObject;
        public static void SetCopyObject(DData obj)
        {
            copyObject = obj;
        }

        public static DData GetCopyObject()
        {
            return copyObject;
        }

        public static bool CheckCompatible(TType target, DData obj)
        {
            if (obj != null)
            {
                if (obj.DType.GetType() == target.GetType() && target.IsPrimitive())
                {
                    return true;
                }
                if (target is TBean)
                {
                    var tbean = target as TBean;

                    if (tbean.BeanType.IsDynamic)
                    {
                        if (obj is DDynamicBean dobj && tbean.BeanType == (dobj.DType as TBean).BeanType)
                            return true;
                    }
                    else
                    {
                        if (obj is DBean bobj && tbean.BeanType == (bobj.DType as TBean).BeanType)
                            return true;
                    }
                }
            }


            MessageBox.Show("类型不兼容,无法插入");
            return false;

        }

    }
}
